<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>单表管理</title>
<meta name="decorator" content="default" />
<script type="text/javascript">
	$(document).ready(
			function() {
				//$("#name").focus();
				$("#inputForm")
						.validate(
								{
									submitHandler : function(form) {
										loading('正在提交，请稍等...');
										form.submit();
									},
									errorContainer : "#messageBox",
									errorPlacement : function(error, element) {
										$("#messageBox").text("输入有误，请先更正。");
										if (element.is(":checkbox")
												|| element.is(":radio")
												|| element.parent().is(
														".input-append")) {
											error.appendTo(element.parent()
													.parent());
										} else {
											error.insertAfter(element);
										}
									}
								});
			});

	$(document).ready(function() {
		uniteTable();
	});

	/////////////////////////////////////////////// 
	//功能：合并表格 
	//参数：tb－需要合并的表格ID 
	//参数：colLength－－需要对前几列进行合并，比如， 
	//想合并前两列，后面的数据列忽略合并，colLength应为2 
	//缺省表示对全部列合并 
	//data:2011.11.06 
	/////////////////////////////////////////////// 
	function uniteTable() {
		var colLength = 2;
		var tb = document.getElementById("contentTable");
		//检查表格是否规整 
		if (!checkTable(tb))
			return;
		var i = 0;
		var j = 0;
		var rowCount = tb.rows.length; //行数 
		var colCount = tb.rows[0].cells.length; //列数 
		var obj1 = null;
		var obj2 = null;
		//为每个单元格命名 
		for (i = 0; i < rowCount; i++) {
			for (j = 0; j < colCount; j++) {
				tb.rows[i].cells[j].id = "tb__" + i.toString() + "_"
						+ j.toString();
			}
		}
		//逐列检查合并 
		for (i = 0; i < colCount; i++) {
			if (i == colLength)
				return;
			obj1 = document.getElementById("tb__0_" + i.toString())
			for (j = 1; j < rowCount; j++) {
				obj2 = document.getElementById("tb__" + j.toString() + "_"
						+ i.toString());
				if (obj1.innerText == obj2.innerText) {
					obj1.rowSpan++;
					obj2.parentNode.removeChild(obj2);
				} else {
					obj1 = document.getElementById("tb__" + j.toString() + "_"
							+ i.toString());
				}
			}
		}
	}

	///////////////////////////////////////// 
	//功能：检查表格是否规整 
	//参数：tb－－需要检查的表格ID 
	//data: 2011.11.06
	///////////////////////////////////////// 
	function checkTable(tb) {
		if (tb.rows.length == 0)
			return false;
		if (tb.rows[0].cells.length == 0)
			return false;
		for (var i = 0; i < tb.rows.length; i++) {
			if (tb.rows[0].cells.length != tb.rows[i].cells.length)
				return false;
		}
		return true;
	}
	
	function audit(orderNo) {
		$.ajax({
			//几个参数需要注意一下
			type : "POST",//方法类型
			dataType : "json",//预期服务器返回的数据类型
			url : "${ctx}/cloudfactory/cloudfactroyOrder/audit?orderNo="+orderNo,//url
		});
		alert("审核完成");
		history.go(-1);
	}
</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/cloudfactory/cloudfactroyOrder/">订单详情</a></li>

	</ul>
	<br /> 订单概述
	<table class="table table-striped table-bordered table-condensed">
		<tr>
			<th>企业名称</th>
			<th>订单编号</th>
			<th>购买用户</th>
			<th>购买时间</th>
			<th>审核状态</th>
			<th>订单总额</th>
		</tr>
		<tr>
			<td>${name}</td>
			<td>${orderNo}</td>
			<td>${userName}</td>
			<td>${date}</td>
			<td>
			${fns:getDictLabel(status, 'audit_status', '')}
			</td>
			<td>${totalMoney}</td>
		</tr>

	</table>
	<br> 订单详情
	<table id="contentTable"
		class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>功能</th>
				<th>功能类别</th>
				<th>功能名称</th>
				<th>购买时长</th>
				<th>对应工厂</th>
				<th>价格</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${cloudfactroyOrder}" var="cloudfactroyOrder">
				<tr>
					<td>${cloudfactroyOrder.menuName}</td>
					<td>${cloudfactroyOrder.isRequired}</td>
					<td>${cloudfactroyOrder.functionName}</td>
					<td>${cloudfactroyOrder.useTime}个月</td>
					<td>${cloudfactroyOrder.plant}</td>
					<td>${cloudfactroyOrder.functionMoney}</td>

				</tr>
			</c:forEach>

		</tbody>
	</table>
	<div class="form-actions">
		<center>
		<c:if test="${status==0}">
			<input id="btnSubmit" class="btn btn-primary" type="submit" onclick="audit('${orderNo}')"
				value="审核通过" />&nbsp;</c:if> <input id="btnCancel" class="btn"
				type="button" value="返回列表" onclick="history.go(-1)" />
		</center>
	</div>
</body>
</html>